/**
 * Created by Administrator on 2017/10/29.
 */
import React from 'react'
import styles  from './swiper.css'

import { Carousel,  WingBlank } from 'antd-mobile';

class Swiper extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            data: this.props.HomeTopSwiperData,
            initialHeight: 238,
            banner:require('./banner.png'),
            swipeSpeed:this.props.swipeSpeed?this.props.swipeSpeed:10,
            speed:this.props.speed?this.props.speed:500
        }
    }

    componentDidMount() {

    }
    componentWillReceiveProps(nextProps){
        //console.log('swiper里面>>HomeTopSwiperData:'+nextProps.HomeTopSwiperData);
    }
    render() {
        const hProp ={ height: '2.24rem',borderRadio:'0.25rem' };
        return (
            <WingBlank>
                {this.props.HomeTopSwiperData?<Carousel
                    className="my-carousel"
                    autoplay={true}
                    infinite
                    selectedIndex={1}
                    dots={false}
                    swipeSpeed={this.state.swipeSpeed}
                    speed={this.state.speed}
                >
                    {this.props.HomeTopSwiperData.map(ii => (
                        <a href={ii.web_url} key={ii} style={hProp}>
                            <img
                                src={ii.image_url}
                                alt=""
                                onLoad={() => {
                                    // fire window resize event to change height
                                    window.dispatchEvent(new Event('resize'));
                                    this.setState({
                                        initialHeight: null,
                                    });
                                }}
                            />
                        </a>
                    ))}
                </Carousel>:''}

            </WingBlank>
        );
    }
}



export default Swiper
